package com.kuang.web;

import com.kuang.util.Ip2Region;
import com.kuang.util.IpUtile;
import org.lionsoul.ip2region.DbMakerConfigException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@Controller
public class Test {


    @RequestMapping("/iptest")
    @ResponseBody
    public String ttt(HttpServletRequest request) throws DbMakerConfigException, IOException {
        String remoteAddr = IpUtile.getRemoteAddr(request);
        System.out.println("remoteAddr = " + remoteAddr);
        String requestURI = request.getRequestURI();
        System.out.println("requestURI = " + requestURI);
        String ipRegion = Ip2Region.getIpRegion(remoteAddr);
        System.out.println("ipRegion = " + ipRegion);
        return requestURI;
    }

}
